$(document).ready(function($) {
	//获取登录信息
	getUser();
	//	$("#siframe").height(7020)
	$('.theme-login').click(function() {
		$('.theme-popover-mask').show();
		$('.theme-popover-mask').height($(document).height());
		$('.theme-popover1').slideDown(200);
	});
	$('.theme-poptit .close').click(function() {
		$('.theme-popover-mask').hide();
		$('.theme-popover').slideUp(200);
		window.location.reload();
	})
	$('#dl').click(function() {
		//alert(window.location.href);
		window.location.href = "login.html?redirectURL=" + encodeURI(window.location.href)
	});
	//退出登录
	$("#logOut").click(function() {
		logOut();
	});
	//		xx关闭
	$(".closex").click(function() {
		try {
			$(this).parent("div").remove();
		} catch(e) {
			//TODO handle the exception
		}
	})
});
//图片垂直旋转
$(function() {
		var aLi = $('.part');
		var aSpan = $('.part').find('.img2');
		var aImg = $('.part').find('.img1');
		$('.part').each(function(index) {
			$(this).mouseover(function() {
				aImg.eq(index).stop();
				aSpan.eq(index).stop();
				aImg.eq(index).animate({
					width: 0,
					height: 140,
					left: 70
				}, 80, '', function() {
					$(this).hide();
					aSpan.eq(index).show().animate({
						width: 140,
						left: 0
					}, 80)
				})
			})
			$(this).mouseout(function() {
				aImg.eq(index).stop();
				aSpan.eq(index).stop();
				aSpan.eq(index).animate({
					width: 0,
					left: 70
				}, 80, '', function() {
					$(this).hide();
					aImg.eq(index).show().animate({
						width: 140,
						left: 0
					}, 80)
				})
			})
		})
	})
	//点击登录
function loginnow() {
	var telNum;
	var passWord;
	telNum = $("#telNum").val();
	passWord = $("#passWord").val();

	if(telNum == '' || passWord == '') {
		alert("账户名密码不完整");
		return
	}
	$.ajax({
		url: '/baby/sys/login', // 跳转到 action  
		data: {
			username: telNum,
			password: passWord,

		},
		type: 'post',
		cache: false,
		dataType: 'json',
		success: function(data) {
			if(data.code == "2000") {
				window.location.reload();
			} else {
				alert(data.message);
			}
		},
		error: function() {
			// view("异常！");  

		}
	});

}
//获取登录信息	
function getUser() {
	$.ajax({
		url: '/baby/sys/getUserInfo', // 跳转到 action  
		data: {},
		type: 'post',
		cache: false,
		dataType: 'json',
		success: function(data) {
			if(data.code == "2000") {
				$("#lg").html("").css({
					"background-color": "transparent"
				});
				$('#ou').hide(); //未登录的隐藏
				$("#lu").show(); //登录的显示

				var imgurl = ''
					//alert(data.data.userHeadPic.length);
				if(data.data.userHeadPic.length < 54) {
					imgurl = 'img/login.png';
				} else {
					imgurl = data.data.userHeadPic;
				}

				$("#ln").attr("src", imgurl);
				//setCookie("username", encodeURI(data.data.userName));
				//console.log(decodeURI(data.data.userName));
				//					window.location.href = 'index.html'
				// window.location.reload();
			} else {
				$('#lu').hide(); //登录的隐藏
				$("#ou").show(); //未登录的显示
			}
		},
		error: function() {
			// view("异常！");  

		}
	});
}
//退出登录
function logOut() {
	$.ajax({
		url: '/baby/sys/logout', // 跳转到 action  
		data: {},
		type: 'post',
		cache: false,
		dataType: 'json',
		success: function(data) {
			if(data.code == "2000") {
				alert('退出成功');
				// deleteCookie("username");
				window.location.href = "home.html";
			}
		},
		error: function() {
			// view("异常！");
		}
	});
}
//悬浮广告
window.onscroll = function() {
		var t = $(".top-line").offset().top - $(window).scrollTop();
		var z = document.documentElement.scrollTop || document.body.scrollTop;
		var advers = document.getElementById("advers");
		var sadver = document.getElementById("sadver");
		var scrolldown = document.getElementById("scrolldown");
		var uptop = document.getElementById("uptop");
		try {
			if(t < 0) {
				advers.style.display = "block";
				sadver.style.display = "block";
				uptop.style.display = "block";
			} else {
				advers.style.display = "none";
				sadver.style.display = "none";
				uptop.style.display = "none";
			}
			if(z >= 1) {
				scrolldown.style.display = "none";
			} else {
				scrolldown.style.display = "block";
			}
		} catch(e) {
			//TODO handle the exception
		}
	}
	//	id跳转
	//	function tiao(ww){
	//		var u=document.getElementById("33").innerHTML;
	//		if(ww!=""){
	//			window.location.href(ww);
	//		}else{
	//			window.location.href("TV.html?"+u);
	//		}
	
	
//$(document).ready(function(){
//	function reflect(){
//	window.location.href = TV.html#video;
//}
//function reflect2(){
//	window.location.href = TV.html#mother;
//}
//function reflect3(){
//	window.location.href = TV.html#activity;
//}
//})
